//登录页面
$(function () {

    var u1 = $('.cont .p1 input');
    var p1 = $('.cont .p2 input');

    let reg1 = /^[a-zA-Z]{6,12}$/;//用户名
    let reg2 = /^(\w){6,20}$/;//密码
    //登录校验
    getZhengze2(u1, reg1, '用户名可用', '用户名不可用');
    getZhengze2(p1, reg2, '密码可用', '密码不可用');


    //登录
    $('.right_all .loggin').on('click', function () {
        let $user = u1.val();
        let $pass = p1.val();

        if ($user && $pass) {
            $.post('php/login.php', { 'username': $user, 'userpass': $pass }, function (reg) {
                if (reg == '1') {
                    alert('登陆成功!即将为您跳转到首页!');
                    setCookie('username', $user, 7);
                    console.log(1);
                    $(window).prop('location', 'index.html')
                } else {
                    alert('登陆失败,请重新登录!');
                }
            })
        }else{
            alert('请输入内容');
        }
    })

    //点进密码框的眼睛，显示密码内容
    yanjing($('.right_all .p2 .icon-yanjing-bi'), $('.right_all .p2 .icon-yanjing_kai'))

})

